import {Base} from "../../utils/base.js";

class Model extends Base{
  constructor(){
    super()
  }

  // 获取图片等资源
  getUserRequest(callback){
    this.request({
      url: '/get_user_request',
      success: function (res) {
        callback(res);
      }
    });
  } 

  // 获取用户信息
  getUserInfo(callback){   
    this.request({
      url: '/get_user_info',
      success: function (res) {
        callback && callback(res);
      },
      fail:function(res){
        callback && callback(res);
      }
    });
  }

  // 发送短信验证码
  sendsms(mobile, callback) {
    this.request({
      type: "POST",
      url: '/send_sms',
      data: {
        mobile: mobile
      },
      success: function (res) {
        callback&&callback(res);
      },
      fail:function(res){
        callback && callback(res);
      }
    });
  }

  // 验证短信验证码
  checkSmsCode(mobile, code, callback) {
    this.request({
      type: "POST",
      url: '/check_sms_code',
      data: {
        mobile: mobile,
        code: code
      },
      success: function (res) {
        callback&&callback(res.data);
      },
      fail:function(res){
        callback&&callback(res)
      }
    });
  }

  setHCard(invite,success,fail){
    this.request({
      type: "POST",
      url: '/set_user_card/'+invite,
      success: function (res) {
        success&&success(res.data);
      },
      fail:function(res){
        fail&&fail(res)
      }
    });
  }

}

export{Model}